<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>学习vue基本语法规则</title>
    <!-- 导入vue库依赖 -->
    <script src="./js/vue.js"></script>
    <script src="./js/vue-router.js"></script>

    <style>
        [v-cloak] {
            display: none;
        }
    </style>
</head>

<body>
    <div id="app">
        <!-- vue 语法之插值表达式 -->
        <span v-cloak>{{msg}}</span>
        <div>
            <!-- 数据的双向绑定 v-model -->
            <input type="text" name="" value="" v-model='msg'>
        </div>

        <p>--------------------</p>

        <div>
            <button v-on:click='handle1'>事件绑定之1</button> <button v-on:click='handle2(123, 456, $event)'>事件绑定之二</button>
        </div>
        <div>
            <button v-on:click='(event) => {handle3(event)}'>事件绑定之三</button> <button
                v-on:click='handle4($event,123)'>事件绑定之四</button>
        </div>

        <p>--------------v-model的底层实现原理--------------</p>

        <!-- 数据的双向绑定的底层原理 v-model-->

        <div>
            <!-- <input type="" name="" value="" v-model='msg1'> -->
            <input type="" name="" v-on:input='handleInput' v-bind:value='msg1'>
        </div>
        <div>
            <span>{{msg1}}</span>
        </div>
    </div>
    <!-- 指令学习之v-cloak -->
    <!-- 指令就是指的自定义属性  -->
    <script>
        // 自定义按键指令 v-on:keyup.f1
        Vue.config.keyCodes.f1 = 112
        var vm = new Vue({
            el: '#app',
            data: {
                msg: 'Hello world !',
                msg1: 'v-model另一种实现方式'
            },
            methods: {
                handle1(event) {
                    console.log('1' + event.target.innerHTML);
                },
                handle2(p1, p2, event) {
                    console.log('2' + '-----' + p1 + ' ----' + p2 + '------ ' + event.target.innerHTML);
                },
                handle3(event) {
                    console.log('3 -----' + event.target.innerHTML);
                },
                handle4(event, p1) {
                    console.log('4 -----' + event.target.innerHTML + '-----' + p1);
                },
                handleInput(event) {
                    this.msg1 = event.target.value
                }
            },
        })
    </script>
</body>

</html>